home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / dskut / toadshr1.zip / STDERR.ASM < prev    next >
Assembly Source File  |  1989-06-14  |  1KB  |  57 lines

  1. ;Output a string to StdErr.
  2. ;Program Author: David Kirschbaum, Toad Hall
  3. ;
  4. ;Declare as follows:
  5. ;    {$F+}
  6. ;    {$L STDERR}
  7. ;    PROCEDURE Write_StdErr(S : STRING); EXTERNAL;
  8. ;
  9. ;Courtesy of Toad Hall
  10.  
  11.  
  12. ;Total stack (caller's plus work stack)
  13. cstk    STRUC
  14. bpsave    dw    0            ;save BP here
  15. retaddr    dd    0            ;points to return address
  16. straddr    dd    0            ;points to string address
  17. cstk    ENDS
  18.  
  19. PARAMSIZE    EQU SIZE straddr    ;size of parameter list
  20.  
  21. PUBLIC    Write_StdErr            ;procedure name declaration
  22.  
  23. CODE    SEGMENT PARA PUBLIC 'CODE'
  24.     ASSUME    CS:CODE
  25.  
  26. ;Entry point to PosCH function
  27.  
  28. Write_StdErr    proc    FAR
  29.     push    bp
  30.     mov    bp,sp
  31.  
  32.     mov    di,DS            ;save caller's DS
  33.  
  34.     cld
  35.     lds    si,[bp.straddr]        ;string
  36.     xor    ah,ah            ;clear msb
  37.     lodsb                ;length byte, bump SI
  38.     mov    cx,ax            ;length into CX
  39.     jcxz    No_Write        ;empty string, forget it
  40.  
  41.     mov    dx,si            ;DS:DX -> DTA
  42.     mov    bx,2            ;STDERR
  43.     mov    ah,40H            ;Write to file/device
  44.     int    21H
  45.  
  46. No_Write:
  47.     mov    DS,di            ;restore caller's DS
  48.  
  49.     mov    sp,bp            ;recover last stack psn
  50.     pop    bp            ;recover BP
  51.     ret    PARAMSIZE
  52.  
  53. Write_StdErr    ENDP
  54.  
  55. CODE    ENDS
  56.     END
  57.